﻿Imports System.ComponentModel

Namespace Forms
    Public Class MDIChildFormBase
        Inherits Form

        Private components As Container = Nothing

        Public Sub New()
            InitializeComponent()
        End Sub

        Protected Overrides Sub Dispose(disposing As Boolean)
            If disposing Then
                If components IsNot Nothing Then
                    components.Dispose()
                End If
            End If
            MyBase.Dispose(disposing)
        End Sub

        Private Sub InitializeComponent()

        End Sub

        Public Property TabPag As TabPage
        Public Property TabCtrl As TabControl

        Private Sub MDIChildFormBase_Closing(sender As Object, e As FormClosingEventArgs) Handles Me.Closing
            TabPag.Dispose()
            If Not TabCtrl.HasChildren Then TabCtrl.Visible = False
        End Sub

        Private Sub MDIChildFormBase_Activated(sender As Object, e As EventArgs) Handles Me.Activated
            TabCtrl.SelectedTab = TabPag
            If Not TabCtrl.Visible Then TabCtrl.Visible = True
        End Sub
    End Class
End Namespace